﻿//   SiteContactInfoWebPartUserControl.ascx.cs
//   Copyright (c) 2012 Eswar Prakash
// 
//    This library is free software; you can redistribute it and/or modify  
//    it  under the terms of the GNU Lesser General Public License version  
//    2.1 as published by the Free Software Foundation.                     
//                                                                          
//    This library is distributed in the hope that it will be useful, but   
//    WITHOUT ANY WARRANTY; without even the implied warranty of            
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     
//    Lesser General Public License for more details.                       
//                                                                          
//    You should have received a copy of the GNU Lesser General Public      
//    License along with this library; if not, write to the Free Software   
//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  
//    USA
namespace CKSAS.Samples.AppStorage.WebParts
{
    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using Microsoft.SharePoint;
    using CKSAS.AppStorage;
    using Microsoft.SharePoint.WebControls;

    /// <summary>
    /// Implements the code behind for SiteContactInfoWebPartUserControl.ascx
    /// </summary>
    public partial class SiteContactInfoWebPartUserControl : UserControl
    {
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            var currentWeb = SPContext.Current.Web;
            var manager = new AppStorageManager(currentWeb);
            var currentSettings = manager.GetObject<ContactSettings>("ContactSettings");
            if (currentSettings != null)
            {
                this.labelFullName.Text = currentSettings.FullName;
                this.labelEmailAddress.Text = currentSettings.EmailAddress;
                this.labelMobileNumber.Text = currentSettings.MobileNumber;
                this.labelTelephoneNumber.Text = currentSettings.TelephoneNumber;
            }

            base.OnLoad(e);
        }
    }
}